﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;


namespace Common
{
    public class FormatDataGrid
    {
        public static FormatDataGrid Instance()
        {
            return new FormatDataGrid();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="columnBold"></param>
        /// <param name="valueBold"></param>
        public void FormatBoldGrid(DataGridView grid, string columnBold, string valueBold)
        {
            int columnCount = grid.ColumnCount;

            foreach (DataGridViewRow row in grid.Rows)
            {
                if (row.Cells[columnBold].Value != null)
                {
                    if (row.Cells[columnBold].Value.ToString() == valueBold)
                    {
                        for (int i = 0; i < columnCount; i++)
                            row.Cells[i].Style.Font = new Font(grid.Font, FontStyle.Bold);
                    }
                }
            }
            grid.Refresh();
        }


        public void FormatItalicGrid(DataGridView grid, string columnBold, string valueItalic)
        {
            int columnCount = grid.ColumnCount;

            foreach (DataGridViewRow row in grid.Rows)
            {
                if (row.Cells[columnBold].Value != null)
                {
                    if (row.Cells[columnBold].Value.ToString() == valueItalic)
                    {
                        for (int i = 0; i < columnCount; i++)
                            row.Cells[i].Style.Font = new Font(grid.Font, FontStyle.Italic);
                    }
                }
            }
            grid.Refresh();
        }

        public void FormatStrikeoutGrid(DataGridView grid, string columnBold, string valueStrikeout)
        {
            int columnCount = grid.ColumnCount;

            foreach (DataGridViewRow row in grid.Rows)
            {
                if (row.Cells[columnBold].Value != null)
                {
                    if (row.Cells[columnBold].Value.ToString() == valueStrikeout)
                    {
                        for (int i = 0; i < columnCount; i++)
                            row.Cells[i].Style.Font = new Font(grid.Font, FontStyle.Strikeout);
                    }
                }
            }

            grid.Refresh();
        }

        public void FormatUnderlineGrid(DataGridView grid, string columnBold, string valueUnderline)
        {
            int columnCount = grid.ColumnCount;

            foreach (DataGridViewRow row in grid.Rows)
            {
                if (row.Cells[columnBold].Value != null)
                {
                    if (row.Cells[columnBold].Value.ToString() == valueUnderline)
                    {
                        for (int i = 0; i < columnCount; i++)
                            row.Cells[i].Style.Font = new Font(grid.Font, FontStyle.Underline);
                    }
                }
            }
            grid.Refresh();
        }

    }
}
